import * as serviceApi from '../services/hbl';
import * as mblServiceApi from '../services/mbl';

export default {
  namespace: 'hbl',

  state: {
    title: 'HBL'
  },

  effects: {
    *getByMBLNo({ payload, callback }, { call, put }) {
      const res = yield call(serviceApi.getByMBLNo, payload)
      if (callback)
        callback(res);
    },
    *update({ payload, callback }, { call, put }) {
      const res = yield call(serviceApi.update, payload);
      if (callback)
        callback(res);
    },
    *addNew({ payload, callback }, { call, put }) {
      const res = yield call(serviceApi.addNew, payload);
      if (callback)
        callback(res);
    },
    *createOrUpdateHBL({ payload, callback }, { call, put }) {
      const res = yield call(serviceApi.createOrUpdateHBL, payload);
      if (callback)
        callback(res);
    },
    *remove({ payload, callback }, { call, put }) {
      const res = yield call(serviceApi.remove, payload);
      if (callback)
        callback(res);
    },
    *changeFHState({ payload, callback }, { call, put }) {
      const res = yield call(mblServiceApi.changeFHState, payload);
      if (callback)
        callback(res);
    },
  },

  reducers: {},
};
